

package com.springboot.rmq.comm;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.rocketmq.client.producer.SendCallback;
import org.apache.rocketmq.client.producer.SendResult;


public class MsgSendCallback implements SendCallback {

    /**
     * 日志
     */
    private Log logger = LogFactory.getLog(MsgSendCallback.class);

    /**
     * 消息名称
     */
    private String moduleName = "";

    public MsgSendCallback() {
    }

    public MsgSendCallback(String moduleName) {
        this.moduleName = moduleName;
    }

    public MsgSendCallback(Log logger, String moduleName) {
        this.logger = logger;
        this.moduleName = moduleName;
    }

    @Override
    public void onSuccess(SendResult sendResult) {
        logger.info("生产" + moduleName + "消息成功: " + sendResult);
    }

    @Override
    public void onException(Throwable throwable) {
        logger.info("生产" + moduleName + "消息失败. ", throwable);
    }
}
